<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/favicon.ico?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.ico?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.ico?v=5.1.4">


  <link rel="mask-icon" href="/images/facicon.ico?v=5.1.4" color="#222">





  <meta name="keywords" content="Node.js,NPM,">





  <link rel="alternate" href="/atom.xml" title="Key" type="application/atom+xml">






<meta name="description" content="概述本文档的内容是package.json配置里边的属性含义。package.json必须是一个严格的json文件，而不仅仅是js里边的一个对象。其中很多属性可以通过npm-config来生成。    namepackage.json中最重要的属性是name和version两个属性，这两个属性是必须要有的，否则模块就无法被安装，这两个属性一起形成了一个npm模块的唯一标识符。模块中内容变更的同时，">
<meta name="keywords" content="Node.js,NPM">
<meta property="og:type" content="article">
<meta property="og:title" content="npm package.json属性详解">
<meta property="og:url" content="https://blog.qipo.net/2018/09/10/package/index.html">
<meta property="og:site_name" content="Key">
<meta property="og:description" content="概述本文档的内容是package.json配置里边的属性含义。package.json必须是一个严格的json文件，而不仅仅是js里边的一个对象。其中很多属性可以通过npm-config来生成。    namepackage.json中最重要的属性是name和version两个属性，这两个属性是必须要有的，否则模块就无法被安装，这两个属性一起形成了一个npm模块的唯一标识符。模块中内容变更的同时，">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2020-06-03T02:37:45.304Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="npm package.json属性详解">
<meta name="twitter:description" content="概述本文档的内容是package.json配置里边的属性含义。package.json必须是一个严格的json文件，而不仅仅是js里边的一个对象。其中很多属性可以通过npm-config来生成。    namepackage.json中最重要的属性是name和version两个属性，这两个属性是必须要有的，否则模块就无法被安装，这两个属性一起形成了一个npm模块的唯一标识符。模块中内容变更的同时，">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://blog.qipo.net/2018/09/10/package/">





  <title>npm package.json属性详解 | Key</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Key</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description"></h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://blog.qipo.net/2018/09/10/package/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Key">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Key">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">npm package.json属性详解</h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-09-10T21:07:25+08:00">
                2018-09-10
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Node-js/" itemprop="url" rel="index">
                    <span itemprop="name">Node.js</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  4.3k
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  17
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h1><p>本文档的内容是package.json配置里边的属性含义。package.json必须是一个严格的json文件，而不仅仅是js里边的一个对象。其中很多属性可以通过npm-config来生成。   </p>
<h1 id="name"><a href="#name" class="headerlink" title="name"></a>name</h1><p>package.json中最重要的属性是name和version两个属性，这两个属性是必须要有的，否则模块就无法被安装，这两个属性一起形成了一个npm模块的唯一标识符。模块中内容变更的同时，模块版本也应该一起变化。<br>name属性就是你的模块名称，下面是一些命名规则:<br>name必须小于等于214个字节，包括前缀名称在内（如 xxx/xxxmodule）。    </p>
<ul>
<li>name不能以”_”或”.”开头    </li>
<li>不能含有大写字母    </li>
<li>name会成为url的一部分，不能含有url非法字符   </li>
</ul>
<p>下面是官网文档的一些建议：   </p>
<ul>
<li>不要使用和node核心模块一样的名称     </li>
<li>name中不要含有”js”和”node”。 It’s assumed that it’s js, since you’re writing a package.json file, and you can specify the engine using the “engines” field. (See below.)</li>
<li>name属性会成为模块url、命令行中的一个参数或者一个文件夹名称，任何非url安全的字符在name中都不能使用，也不能以”_”或”.”开头</li>
<li>name属性也许会被写在require()的参数中，所以最好取个简短而语义化的值。</li>
<li>创建一个模块前可以先到后边的网址查查name是否已经被占用. <a href="https://www.npmjs.com/" target="_blank" rel="noopener">https://www.npmjs.com/</a>    </li>
</ul>
<p>name属性可以有一些前缀如 e.g. @myorg/mypackage.在npm-scope(7)的文档中可以看到详细说明    </p>
<h1 id="version"><a href="#version" class="headerlink" title="version"></a>version</h1><p>version必须可以被npm依赖的一个node-semver模块解析。具体规则见下面的dependencies模块    </p>
<h1 id="description"><a href="#description" class="headerlink" title="description"></a>description</h1><p>一个描述，方便别人了解你的模块作用，搜索的时候也有用。    </p>
<h1 id="keywords"><a href="#keywords" class="headerlink" title="keywords"></a>keywords</h1><p>一个字符串数组，方便别人搜索到本模块    </p>
<h1 id="homepage"><a href="#homepage" class="headerlink" title="homepage"></a>homepage</h1><p>项目主页url<br><strong>注意:</strong> 这个项目主页url和url属性不同，如果你填写了url属性，npm注册工具会认为你把项目发布到其他地方了，获取模块的时候不会从npm官方仓库获取，而是会重定向到url属性配置的地址。<br>（原文档中用了 spit(吐)这个单词，作者表示他不是在开玩笑:）    </p>
<h1 id="bugs"><a href="#bugs" class="headerlink" title="bugs"></a>bugs</h1><p>填写一个bug提交地址或者一个邮箱，被你的模块坑到的人可以通过这里吐槽，例如：    </p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&#123; <span class="attr">"url"</span> : <span class="string">"https://github.com/owner/project/issues"</span></span><br><span class="line">, <span class="attr">"email"</span> : <span class="string">"project@hostname.com"</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>url和email可以任意填或不填，如果只填一个，可以直接写成一个字符串而不是对象。如果填写了url，npm bugs命令会使用这个url。    </p>
<h1 id="license"><a href="#license" class="headerlink" title="license"></a>license</h1><p>你应该为你的模块制定一个协议，让用户知道他们有何权限来使用你的模块，以及使用该模块有哪些限制。最简单的，例如你用BSD-3-Clause 或 MIT之类的协议，如下：<br>{ “license” : “BSD-3-Clause” }<br>你可以在<a href="https://spdx.org/licenses/" target="_blank" rel="noopener">https://spdx.org/licenses/ </a>这个地址查阅协议列表 。    </p>
<h1 id="和用户相关的属性-author-contributors"><a href="#和用户相关的属性-author-contributors" class="headerlink" title="和用户相关的属性: author, contributors"></a>和用户相关的属性: author, contributors</h1><p>“author”是一个码农， “contributors”是一个码农数组。 “person”是一个有一些描述属性的对象，如下 like this:   </p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&#123; <span class="attr">"name"</span> : <span class="string">"Barney Rubble"</span></span><br><span class="line">, <span class="attr">"email"</span> : <span class="string">"b@rubble.com"</span></span><br><span class="line">, <span class="attr">"url"</span> : <span class="string">"http://barnyrubble.tumblr.com/"</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>也可以按如下格式缩写，npm会帮着转换:<br>“Barney Rubble <a href="mailto:&#x62;&#64;&#x72;&#x75;&#x62;&#98;&#108;&#x65;&#x2e;&#99;&#x6f;&#x6d;" target="_blank" rel="noopener">&#x62;&#64;&#x72;&#x75;&#x62;&#98;&#108;&#x65;&#x2e;&#99;&#x6f;&#x6d;</a> (<a href="http://barnyrubble.tumblr.com/)&quot;" target="_blank" rel="noopener">http://barnyrubble.tumblr.com/)&quot;</a><br>email和url属性实际上都是可以省略的。描述用户信息的还有一个”maintainers”（维护者）属性。   </p>
<h1 id="files"><a href="#files" class="headerlink" title="files"></a>files</h1><p>“files”属性的值是一个数组，内容是模块下文件名或者文件夹名，如果是文件夹名，则文件夹下所有的文件也会被包含进来（除非文件被另一些配置排除了）<br>你也可以在模块根目录下创建一个”.npmignore”文件（windows下无法直接创建以”.”开头的文件，使用linux命令行工具创建如git bash），写在这个文件里边的文件即便被写在files属性里边也会被排除在外，这个文件的写法”.gitignore”类似。</p>
<h1 id="main"><a href="#main" class="headerlink" title="main"></a>main</h1><p>main属性指定了程序的主入口文件。意思是，如果你的模块被命名为foo，用户安装了这个模块并通过require(“foo”)来使用这个模块，那么require返回的内容就是main属性指定的文件中 module.exports指向的对象。<br>它应该指向模块根目录下的一个文件。对大对数模块而言，这个属性更多的是让模块有一个主入口文件，然而很多模块并不写这个属性。   </p>
<h1 id="bin"><a href="#bin" class="headerlink" title="bin"></a>bin</h1><p>很多模块有一个或多个需要配置到PATH路径下的可执行模块，npm让这个工作变得十分简单（实际上npm本身也是通过bin属性安装为一个可执行命令的）<br>如果要用npm的这个功能，在package.json里边配置一个bin属性。bin属性是一个已命令名称为key，本地文件名称为value的map如下：   </p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&#123; <span class="attr">"bin"</span> : &#123; <span class="attr">"myapp"</span> : <span class="string">"./cli.js"</span> &#125; &#125;</span><br></pre></td></tr></table></figure>
<p>模块安装的时候，若是全局安装，则npm会为bin中配置的文件在bin目录下创建一个软连接（对于windows系统，默认会在C:\Users\username\AppData\Roaming\npm目录下），若是局部安装，则会在项目内的./node_modules/.bin/目录下创建一个软链接。<br>因此，按上面的例子，当你安装myapp的时候，npm就会为cli.js在/usr/local/bin/myapp路径创建一个软链接。<br>如果你的模块只有一个可执行文件，并且它的命令名称和模块名称一样，你可以只写一个字符串来代替上面那种配置，例如：    </p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&#123; <span class="attr">"name"</span>: <span class="string">"my-program"</span></span><br><span class="line">, <span class="attr">"version"</span>: <span class="string">"1.2.5"</span></span><br><span class="line">, <span class="attr">"bin"</span>: <span class="string">"./path/to/program"</span> &#125;</span><br></pre></td></tr></table></figure>
<p>作用和如下写法相同:   </p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&#123; <span class="attr">"name"</span>: <span class="string">"my-program"</span></span><br><span class="line">, <span class="attr">"version"</span>: <span class="string">"1.2.5"</span></span><br><span class="line">, <span class="attr">"bin"</span> : &#123; <span class="attr">"my-program"</span> : <span class="string">"./path/to/program"</span> &#125; &#125;</span><br></pre></td></tr></table></figure>
<h1 id="man"><a href="#man" class="headerlink" title="man"></a>man</h1><p>制定一个或通过数组制定一些文件来让linux下的man命令查找文档地址。<br>如果只有一个文件被指定的话，安装后直接使用man+模块名称，而不管man指定的文件的实际名称。例如:   </p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&#123; <span class="attr">"name"</span> : <span class="string">"foo"</span></span><br><span class="line">, <span class="attr">"version"</span> : <span class="string">"1.2.3"</span></span><br><span class="line">, <span class="attr">"description"</span> : <span class="string">"A packaged foo fooer for fooing foos"</span></span><br><span class="line">, <span class="attr">"main"</span> : <span class="string">"foo.js"</span></span><br><span class="line">, <span class="attr">"man"</span> : <span class="string">"./man/doc.1"</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>通过man foo命令会得到 ./man/doc.1 文件的内容。<br>如果man文件名称不是以模块名称开头的，安装的时候会给加上模块名称前缀。因此，下面这段配置：   </p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&#123; <span class="attr">"name"</span> : <span class="string">"foo"</span></span><br><span class="line">, <span class="attr">"version"</span> : <span class="string">"1.2.3"</span></span><br><span class="line">, <span class="attr">"description"</span> : <span class="string">"A packaged foo fooer for fooing foos"</span></span><br><span class="line">, <span class="attr">"main"</span> : <span class="string">"foo.js"</span></span><br><span class="line">, <span class="attr">"man"</span> : [ <span class="string">"./man/foo.1"</span>, <span class="string">"./man/bar.1"</span> ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>会创建一些文件来作为man foo和man foo-bar命令的结果。<br>man文件必须以数字结尾，或者如果被压缩了，以.gz结尾。数字表示文件将被安装到man的哪个部分。   </p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&#123; <span class="attr">"name"</span> : <span class="string">"foo"</span></span><br><span class="line">, <span class="attr">"version"</span> : <span class="string">"1.2.3"</span></span><br><span class="line">, <span class="attr">"description"</span> : <span class="string">"A packaged foo fooer for fooing foos"</span></span><br><span class="line">, <span class="attr">"main"</span> : <span class="string">"foo.js"</span></span><br><span class="line">, <span class="attr">"man"</span> : [ <span class="string">"./man/foo.1"</span>, <span class="string">"./man/foo.2"</span> ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>会创建 man foo 和 man 2 foo 两条命令。   </p>
<h1 id="directories"><a href="#directories" class="headerlink" title="directories"></a>directories</h1><p>CommonJs通过directories来制定一些方法来描述模块的结构，看看npm的package.json文件<a href="https://registry.npmjs.org/npm/latest" target="_blank" rel="noopener">https://registry.npmjs.org/npm/latest</a> ，可以发现里边有这个字段的内容。   </p>
<figure class="highlight crystal"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="symbol">directories:</span> &#123;</span><br><span class="line"><span class="symbol">bin:</span> <span class="string">"./bin"</span>,</span><br><span class="line"><span class="symbol">doc:</span> <span class="string">"./doc"</span>,</span><br><span class="line"><span class="class"><span class="keyword">lib</span>: "./<span class="title">lib</span>",</span></span><br><span class="line"><span class="symbol">man:</span> <span class="string">"./man"</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>目前这个配置没有任何作用，将来可能会整出一些花样来。   </p>
<h2 id="directories-lib"><a href="#directories-lib" class="headerlink" title="directories.lib"></a>directories.lib</h2><p>告诉用户模块中lib目录在哪，这个配置目前没有任何作用，但是对使用模块的人来说是一个很有用的信息。    </p>
<h2 id="directories-bin"><a href="#directories-bin" class="headerlink" title="directories.bin"></a>directories.bin</h2><p>如果你在这里指定了bin目录，这个配置下面的文件会被加入到bin路径下，如果你已经在package.json中配置了bin目录，那么这里的配置将不起任何作用。  </p>
<h2 id="directories-man"><a href="#directories-man" class="headerlink" title="directories.man"></a>directories.man</h2><p>指定一个目录，目录里边都是man文件，这是一种配置man文件的语法糖。   </p>
<h2 id="directories-doc"><a href="#directories-doc" class="headerlink" title="directories.doc"></a>directories.doc</h2><p>在这个目录里边放一些markdown文件，可能最终有一天它们会被友好的展现出来（应该是在npm的网站上）   </p>
<h2 id="directories-example"><a href="#directories-example" class="headerlink" title="directories.example"></a>directories.example</h2><p>放一些示例脚本，或许某一天会有用 - -！   </p>
<h1 id="repository"><a href="#repository" class="headerlink" title="repository"></a>repository</h1><p>指定一个代码存放地址，对想要为你的项目贡献代码的人有帮助。像这样：   </p>
<figure class="highlight xquery"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"repository"</span> :</span><br><span class="line">  &#123; <span class="string">"type"</span> : <span class="string">"git"</span></span><br><span class="line">  , <span class="string">"url"</span> : <span class="string">"https://github.com/npm/npm.git"</span></span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line"><span class="string">"repository"</span> :</span><br><span class="line">  &#123; <span class="string">"type"</span> : <span class="string">"svn"</span></span><br><span class="line">  , <span class="string">"url"</span> : <span class="string">"https://v8.googlecode.com/svn/trunk/"</span></span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>
<p>若你的模块放在GitHub, GitHub gist, Bitbucket, or GitLab的仓库里，npm install的时候可以使用缩写标记来完成：    </p>
<figure class="highlight 1c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"repository"</span>: <span class="string">"npm/npm"</span></span><br><span class="line"></span><br><span class="line"><span class="string">"repository"</span>: <span class="string">"gist:11081aaa281"</span></span><br><span class="line"></span><br><span class="line"><span class="string">"repository"</span>: <span class="string">"bitbucket:example/repo"</span></span><br><span class="line"></span><br><span class="line"><span class="string">"repository"</span>: <span class="string">"gitlab:another/repo"</span></span><br></pre></td></tr></table></figure>
<h1 id="scripts"><a href="#scripts" class="headerlink" title="scripts"></a>scripts</h1><p>scripts属性是一个对象，里边指定了项目的生命周期个各个环节需要执行的命令。key是生命周期中的事件，value是要执行的命令。<br>具体的内容有 install  start  stop 等，详见<a href="https://docs.npmjs.com/misc/scripts" target="_blank" rel="noopener"> https://docs.npmjs.com/misc/scripts</a>     </p>
<h1 id="config"><a href="#config" class="headerlink" title="config"></a>config</h1><p>用来设置一些项目不怎么变化的项目配置，例如port等。<br>用户用的时候可以使用如下用法：  </p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">http</span><span class="selector-class">.createServer</span>(...)<span class="selector-class">.listen</span>(<span class="selector-tag">process</span><span class="selector-class">.env</span><span class="selector-class">.npm_package_config_port</span>)</span><br></pre></td></tr></table></figure>
<p>可以通过npm config set foo:port 80来修改config。详见<a href="https://docs.npmjs.com/misc/config" target="_blank" rel="noopener">https://docs.npmjs.com/misc/config</a></p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">&#123; <span class="attr">"name"</span> : <span class="string">"foo"</span></span><br><span class="line">, <span class="attr">"config"</span> : &#123; <span class="attr">"port"</span> : <span class="string">"8080"</span> &#125; &#125;</span><br></pre></td></tr></table></figure>
<h1 id="dependencies"><a href="#dependencies" class="headerlink" title="dependencies"></a>dependencies</h1><p>dependencies属性是一个对象，配置模块依赖的模块列表，key是模块名称，value是版本范围，版本范围是一个字符，可以被一个或多个空格分割。<br>dependencies也可以被指定为一个git地址或者一个压缩包地址。<br>不要把测试工具或transpilers写到dependencies中。 下面是一些写法，详见<a href="https://docs.npmjs.com/misc/semver" target="_blank" rel="noopener">https://docs.npmjs.com/misc/semver </a>    </p>
<ul>
<li><code>version</code> 精确匹配版本   </li>
<li><code>&gt;version</code> 必须大于某个版本   </li>
<li><code>&gt;=version</code> 大于等于   </li>
<li><code>&lt;version</code> 小于      </li>
<li><code>&lt;=version</code> 小于等于     </li>
<li><code>~version</code> “约等于”，具体规则详见semver文档   </li>
<li><code>^version</code> “兼容版本”具体规则详见semver文档   </li>
<li><code>1.2.x</code> 仅一点二点几的版本   </li>
<li><code>http://...</code> 见下面url作为denpendencies的说明   </li>
<li><code>*</code>  任何版本   </li>
<li><code>&quot;&quot;</code>  空字符，和*相同   </li>
<li><code>version1 - version2</code> 相当于 <code>&gt;=version1 &lt;=version2</code>.   </li>
<li><code>range1 || range2</code>  范围1和范围2满足任意一个都行   </li>
<li><code>git...</code>  见下面git url作为denpendencies的说明   </li>
<li><code>user/repo</code> See  见下面GitHub仓库的说明   </li>
<li><code>tag</code>  发布的一个特殊的标签，见npm-tag的文档 <a href="https://docs.npmjs.com/getting-started/using-tags" target="_blank" rel="noopener">https://docs.npmjs.com/getting-started/using-tags</a>   </li>
<li><code>path/path/path</code>  见下面本地模块的说明<br>下面的写法都是可以的:   </li>
</ul>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">&#123; <span class="attr">"dependencies"</span> :</span><br><span class="line">  &#123; <span class="attr">"foo"</span> : <span class="string">"1.0.0 - 2.9999.9999"</span></span><br><span class="line">  , <span class="attr">"bar"</span> : <span class="string">"&gt;=1.0.2 &lt;2.1.2"</span></span><br><span class="line">  , <span class="attr">"baz"</span> : <span class="string">"&gt;1.0.2 &lt;=2.3.4"</span></span><br><span class="line">  , <span class="attr">"boo"</span> : <span class="string">"2.0.1"</span></span><br><span class="line">  , <span class="attr">"qux"</span> : <span class="string">"&lt;1.0.0 || &gt;=2.3.1 &lt;2.4.5 || &gt;=2.5.2 &lt;3.0.0"</span></span><br><span class="line">  , <span class="attr">"asd"</span> : <span class="string">"http://asdf.com/asdf.tar.gz"</span></span><br><span class="line">  , <span class="attr">"til"</span> : <span class="string">"~1.2"</span></span><br><span class="line">  , <span class="attr">"elf"</span> : <span class="string">"~1.2.3"</span></span><br><span class="line">  , <span class="attr">"two"</span> : <span class="string">"2.x"</span></span><br><span class="line">  , <span class="attr">"thr"</span> : <span class="string">"3.3.x"</span></span><br><span class="line">  , <span class="attr">"lat"</span> : <span class="string">"latest"</span></span><br><span class="line">  , <span class="attr">"dyl"</span> : <span class="string">"file:../dyl"</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="URLs-as-Dependencies"><a href="#URLs-as-Dependencies" class="headerlink" title="URLs as Dependencies"></a>URLs as Dependencies</h1><p>在版本范围的地方可以写一个url指向一个压缩包，模块安装的时候会把这个压缩包下载下来安装到模块本地。   </p>
<h1 id="Git-URLs-as-Dependencies"><a href="#Git-URLs-as-Dependencies" class="headerlink" title="Git URLs as Dependencies"></a>Git URLs as Dependencies</h1><p>Git url可以像下面一样:</p>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">git://github.com/user/<span class="keyword">project</span>.git<span class="comment">#commit-ish</span></span><br><span class="line">git+ssh://user@hostname:<span class="keyword">project</span>.git<span class="comment">#commit-ish</span></span><br><span class="line">git+ssh://user@hostname/<span class="keyword">project</span>.git<span class="comment">#commit-ish</span></span><br><span class="line">git+http://user@hostname/<span class="keyword">project</span>/blah.git<span class="comment">#commit-ish</span></span><br><span class="line">git+https://user@hostname/<span class="keyword">project</span>/blah.git<span class="comment">#commit-ish</span></span><br></pre></td></tr></table></figure>
<p>commit-ish 可以是任意标签，哈希值，或者可以检出的分支，默认是master分支。   </p>
<h1 id="GitHub-URLs"><a href="#GitHub-URLs" class="headerlink" title="GitHub URLs"></a>GitHub URLs</h1><p>支持github的 username/modulename 的写法，#后边可以加后缀写明分支hash或标签：   </p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  <span class="attr">"name"</span>: <span class="string">"foo"</span>,</span><br><span class="line">  <span class="attr">"version"</span>: <span class="string">"0.0.0"</span>,</span><br><span class="line">  <span class="attr">"dependencies"</span>: &#123;</span><br><span class="line">    <span class="attr">"express"</span>: <span class="string">"visionmedia/express"</span>,</span><br><span class="line">    <span class="attr">"mocha"</span>: <span class="string">"visionmedia/mocha#4727d357ea"</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="Local-Paths"><a href="#Local-Paths" class="headerlink" title="Local Paths"></a>Local Paths</h1><p>npm2.0.0版本以上可以提供一个本地路径来安装一个本地的模块，通过npm install xxx –save 来安装，格式如下：   </p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">..<span class="regexp">/foo/</span>bar</span><br><span class="line">~<span class="regexp">/foo/</span>bar</span><br><span class="line">.<span class="regexp">/foo/</span>bar</span><br><span class="line"><span class="regexp">/foo/</span>bar</span><br></pre></td></tr></table></figure>
<p>package.json 生成的相对路径如下:   </p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  <span class="attr">"name"</span>: <span class="string">"baz"</span>,</span><br><span class="line">  <span class="attr">"dependencies"</span>: &#123;</span><br><span class="line">    <span class="attr">"bar"</span>: <span class="string">"file:../foo/bar"</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>这种属性在离线开发或者测试需要用npm install的情况，又不想自己搞一个npm server的时候有用，但是发布模块到公共仓库时不应该使用这种属性。   </p>
<h1 id="devDependencies"><a href="#devDependencies" class="headerlink" title="devDependencies"></a>devDependencies</h1><p>如果有人想要下载并使用你的模块，也许他们并不希望或需要下载一些你在开发过程中使用的额外的测试或者文档框架。<br>在这种情况下，最好的方法是把这些依赖添加到devDependencies属性的对象中。<br>这些模块会在npm link或者npm install的时候被安装，也可以像其他npm配置一样被管理，详见npm的config文档。<br>对于一些跨平台的构建任务，例如把CoffeeScript编译成JavaScript，就可以通过在package.json的script属性里边配置prepublish脚本来完成这个任务，然后需要依赖的coffee-script模块就写在devDependencies属性种。<br>例如:   </p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">&#123; <span class="attr">"name"</span>: <span class="string">"ethopia-waza"</span>,</span><br><span class="line">  <span class="attr">"description"</span>: <span class="string">"a delightfully fruity coffee varietal"</span>,</span><br><span class="line">  <span class="attr">"version"</span>: <span class="string">"1.2.3"</span>,</span><br><span class="line">  <span class="attr">"devDependencies"</span>: &#123;</span><br><span class="line">    <span class="attr">"coffee-script"</span>: <span class="string">"~1.6.3"</span></span><br><span class="line">  &#125;,</span><br><span class="line">  <span class="attr">"scripts"</span>: &#123;</span><br><span class="line">    <span class="attr">"prepublish"</span>: <span class="string">"coffee -o lib/ -c src/waza.coffee"</span></span><br><span class="line">  &#125;,</span><br><span class="line">  <span class="attr">"main"</span>: <span class="string">"lib/waza.js"</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>prepublish脚本会在发布之前运行，因此用户在使用之前就不用再自己去完成编译的过程了。在开发模式下，运行npm install也会执行这个脚本（见npm script文档），因此可以很方便的调试。   </p>
<h1 id="peerDependencies"><a href="#peerDependencies" class="headerlink" title="peerDependencies"></a>peerDependencies</h1><p>有时候做一些插件开发，比如grunt等工具的插件，它们往往是在grunt的某个版本的基础上开发的，而在他们的代码中并不会出现require(“grunt”)这样的依赖，dependencies配置里边也不会写上grunt的依赖，为了说明此模块只能作为插件跑在宿主的某个版本范围下，可以配置peerDependencies：   </p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  <span class="attr">"name"</span>: <span class="string">"tea-latte"</span>,</span><br><span class="line">  <span class="attr">"version"</span>: <span class="string">"1.3.5"</span>,</span><br><span class="line">  <span class="attr">"peerDependencies"</span>: &#123;</span><br><span class="line">    <span class="attr">"tea"</span>: <span class="string">"2.x"</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>上面这个配置确保再npm install的时候tea-latte会和2.x版本的tea一起安装，而且它们两个的依赖关系是同级的：<br>├── <a href="mailto:tea-latte@1.3.5" target="_blank" rel="noopener">tea-latte@1.3.5</a><br>└── <a href="mailto:tea@2.2.0" target="_blank" rel="noopener">tea@2.2.0</a><br>这个配置的目的是让npm知道，如果要使用此插件模块，请确保安装了兼容版本的宿主模块。   </p>
<h1 id="bundledDependencies"><a href="#bundledDependencies" class="headerlink" title="bundledDependencies"></a>bundledDependencies</h1><p>上面的单词少个d，写成bundleDependencies也可以。<br>指定发布的时候会被一起打包的模块。   </p>
<h1 id="optionalDependencies"><a href="#optionalDependencies" class="headerlink" title="optionalDependencies"></a>optionalDependencies</h1><p>如果一个依赖模块可以被使用， 同时你也希望在该模块找不到或无法获取时npm继续运行，你可以把这个模块依赖放到optionalDependencies配置中。这个配置的写法和dependencies的写法一样，不同的是这里边写的模块安装失败不会导致npm install失败。<br>当然，这种模块就需要你自己在代码中处理模块确实的情况了，例如：   </p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">try</span> &#123;</span><br><span class="line">  <span class="keyword">var</span> foo = <span class="built_in">require</span>(<span class="string">'foo'</span>)</span><br><span class="line">  <span class="keyword">var</span> fooVersion = <span class="built_in">require</span>(<span class="string">'foo/package.json'</span>).version</span><br><span class="line">&#125; <span class="keyword">catch</span> (er) &#123;</span><br><span class="line">  foo = <span class="literal">null</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">if</span> ( notGoodFooVersion(fooVersion) ) &#123;</span><br><span class="line">  foo = <span class="literal">null</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// .. then later in your program ..</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> (foo) &#123;</span><br><span class="line">  foo.doFooThings()</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>optionalDependencies 中的配置会覆盖dependencies中的配置，最好只在一个地方写。   </p>
<h1 id="engines"><a href="#engines" class="headerlink" title="engines"></a>engines</h1><p>你可以指定项目运行的node版本范围，如下：<br>{ “engines” : { “node” : “&gt;=0.10.3 &lt;0.12” } }<br>和dependencies一样，如果你不指定版本范围或者指定为*，任何版本的node都可以。<br>也可以指定一些npm版本可以正确的安装你的模块，例如：<br>{ “engines” : { “npm” : “~1.0.20” } }<br>要注意的是，除非你设置了engine-strict属性，engines属性是仅供参考的。   </p>
<h1 id="engineStrict"><a href="#engineStrict" class="headerlink" title="engineStrict"></a>engineStrict</h1><p>注意：这个属性已经弃用，将在npm 3.0.0 版本干掉。   </p>
<h1 id="os"><a href="#os" class="headerlink" title="os"></a>os</h1><p>可以指定你的模块只能在哪个操作系统上跑：<br>“os” : [ “darwin”, “linux” ]<br>也可以指定黑名单而不是白名单：<br>“os” : [ “!win32” ]<br>服务的操作系统是由process.platform来判断的，这个属性允许黑白名单同时存在，虽然没啥必要这样搞…   </p>
<h1 id="cpu"><a href="#cpu" class="headerlink" title="cpu"></a>cpu</h1><p>限制模块只能在某某cpu架构下运行<br>“cpu” : [ “x64”, “ia32” ]<br>同样可以设置黑名单:<br>“cpu” : [ “!arm”, “!mips” ]<br>cpu架构通过 process.arch 判断   </p>
<h1 id="preferGlobal"><a href="#preferGlobal" class="headerlink" title="preferGlobal"></a>preferGlobal</h1><p>如果您的软件包主要用于安装到全局的命令行应用程序，那么该值设置为true ，如果它被安装在本地，则提供一个警告。实际上该配置并没有阻止用户把模块安装到本地，只是防止该模块被错误的使用引起一些问题。   </p>
<h1 id="private"><a href="#private" class="headerlink" title="private"></a>private</h1><p>如果这个属性被设置为true，npm将拒绝发布它，这是为了防止一个私有模块被无意间发布出去。如果你只想让模块被发布到一个特定的npm仓库，如一个内部的仓库，可与在下面的publishConfig中配置仓库参数。  </p>
<h1 id="publishConfig"><a href="#publishConfig" class="headerlink" title="publishConfig"></a>publishConfig</h1><p>这个配置是会在模块发布时用到的一些值的集合。如果你不想模块被默认被标记为最新的，或者默认发布到公共仓库，可以在这里配置tag或仓库地址。  </p>
<h1 id="DEFAULT-VALUES"><a href="#DEFAULT-VALUES" class="headerlink" title="DEFAULT VALUES"></a>DEFAULT VALUES</h1><p>npm设置了一些默认参数，如：<br>“scripts”: {“start”: “node server.js”}<br>如果模块根目录下有一个server.js文件，那么npm start会默认运行这个文件。<br>“scripts”:{“preinstall”: “node-gyp rebuild”}<br>如果模块根目录下有binding.gyp, npm将默认用node-gyp来编译preinstall的脚本<br>“contributors”: […]<br>若模块根目录下有AUTHORS 文件，则npm会按Name <email> (url)格式解析每一行的数据添加到contributors中，可以用#添加行注释   </email></p>
<h1 id="参考文档列表-https-docs-npmjs-com"><a href="#参考文档列表-https-docs-npmjs-com" class="headerlink" title="参考文档列表(https://docs.npmjs.com/)"></a>参考文档列表(<a href="https://docs.npmjs.com/" target="_blank" rel="noopener">https://docs.npmjs.com/</a>)</h1><p>semver(7)<br>npm-init(1)<br>npm-version(1)<br>npm-config(1)<br>npm-config(7)<br>npm-help(1)<br>npm-faq(7)<br>npm-install(1)<br>npm-publish(1)<br>npm-rm(1)   </p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div></div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wechatpay.jpg" alt="Key 微信支付">
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.jpg" alt="Key 支付宝">
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Node-js/" rel="tag"># Node.js</a>
          
            <a href="/tags/NPM/" rel="tag"># NPM</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/07/08/deepcopy/" rel="next" title="JavaScript深度克隆">
                <i class="fa fa-chevron-left"></i> JavaScript深度克隆
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/09/11/markdown/" rel="prev" title="markdown">
                markdown <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/avatar.jpg" alt="Key">
            
              <p class="site-author-name" itemprop="name">Key</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">107</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">28</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/keyarea" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:wxkayle@gmail.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#概述"><span class="nav-number">1.</span> <span class="nav-text">概述</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#name"><span class="nav-number">2.</span> <span class="nav-text">name</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#version"><span class="nav-number">3.</span> <span class="nav-text">version</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#description"><span class="nav-number">4.</span> <span class="nav-text">description</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#keywords"><span class="nav-number">5.</span> <span class="nav-text">keywords</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#homepage"><span class="nav-number">6.</span> <span class="nav-text">homepage</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#bugs"><span class="nav-number">7.</span> <span class="nav-text">bugs</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#license"><span class="nav-number">8.</span> <span class="nav-text">license</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#和用户相关的属性-author-contributors"><span class="nav-number">9.</span> <span class="nav-text">和用户相关的属性: author, contributors</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#files"><span class="nav-number">10.</span> <span class="nav-text">files</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#main"><span class="nav-number">11.</span> <span class="nav-text">main</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#bin"><span class="nav-number">12.</span> <span class="nav-text">bin</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#man"><span class="nav-number">13.</span> <span class="nav-text">man</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#directories"><span class="nav-number">14.</span> <span class="nav-text">directories</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#directories-lib"><span class="nav-number">14.1.</span> <span class="nav-text">directories.lib</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#directories-bin"><span class="nav-number">14.2.</span> <span class="nav-text">directories.bin</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#directories-man"><span class="nav-number">14.3.</span> <span class="nav-text">directories.man</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#directories-doc"><span class="nav-number">14.4.</span> <span class="nav-text">directories.doc</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#directories-example"><span class="nav-number">14.5.</span> <span class="nav-text">directories.example</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#repository"><span class="nav-number">15.</span> <span class="nav-text">repository</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#scripts"><span class="nav-number">16.</span> <span class="nav-text">scripts</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#config"><span class="nav-number">17.</span> <span class="nav-text">config</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#dependencies"><span class="nav-number">18.</span> <span class="nav-text">dependencies</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#URLs-as-Dependencies"><span class="nav-number">19.</span> <span class="nav-text">URLs as Dependencies</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Git-URLs-as-Dependencies"><span class="nav-number">20.</span> <span class="nav-text">Git URLs as Dependencies</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#GitHub-URLs"><span class="nav-number">21.</span> <span class="nav-text">GitHub URLs</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Local-Paths"><span class="nav-number">22.</span> <span class="nav-text">Local Paths</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#devDependencies"><span class="nav-number">23.</span> <span class="nav-text">devDependencies</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#peerDependencies"><span class="nav-number">24.</span> <span class="nav-text">peerDependencies</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#bundledDependencies"><span class="nav-number">25.</span> <span class="nav-text">bundledDependencies</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#optionalDependencies"><span class="nav-number">26.</span> <span class="nav-text">optionalDependencies</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#engines"><span class="nav-number">27.</span> <span class="nav-text">engines</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#engineStrict"><span class="nav-number">28.</span> <span class="nav-text">engineStrict</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#os"><span class="nav-number">29.</span> <span class="nav-text">os</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#cpu"><span class="nav-number">30.</span> <span class="nav-text">cpu</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#preferGlobal"><span class="nav-number">31.</span> <span class="nav-text">preferGlobal</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#private"><span class="nav-number">32.</span> <span class="nav-text">private</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#publishConfig"><span class="nav-number">33.</span> <span class="nav-text">publishConfig</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#DEFAULT-VALUES"><span class="nav-number">34.</span> <span class="nav-text">DEFAULT VALUES</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#参考文档列表-https-docs-npmjs-com"><span class="nav-number">35.</span> <span class="nav-text">参考文档列表(https://docs.npmjs.com/)</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2018 &mdash; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-snowflake-o"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Key</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">190.8k</span>
  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
